package com.tim.service.Impl;

import com.tim.dao.Impl.UserDaoImpl;
import com.tim.dao.UserDao;
import com.tim.pojo.User;
import com.tim.service.UserService;

import java.sql.SQLException;

/**
 * 作者：Tim
 * 时间：2021/4/25 14:31
 */
public class UserServiceImpl implements UserService {
    UserDao userDao = new UserDaoImpl();
    @Override
    public boolean selectUserByname(User user) {
        try {
            User u = userDao.selectByname(user.getUsername());
            if(u!=null){
                if(u.getPassword().equals(user.getPassword())){
                    return true;
                }
            }
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return false;
    }

    @Override
    public boolean selectUserByname(String username) {
        try {
            User u = userDao.selectByname(username);
            if(u!=null){
                return true;
            }
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return false;
    }
}
